package com.lx.pc.service.category.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lx.pc.domain.entity.category.CategoryEntity;
import com.lx.pc.domain.vo.category.CategoryVo;
import com.lx.pc.mybatis.repository.category.CategoryRepository;
import com.lx.pc.service.AbstractService;
import com.lx.pc.service.category.ICategoryService;
import com.lx.pc.utils.OmsPage;

@Service("categoryService")
public class CategoryServiceImpl extends AbstractService<CategoryEntity, CategoryVo, BigInteger, CategoryRepository> implements ICategoryService{

	@Override
	public int findByCategoryCount(CategoryVo category) {

		return repository.findByCategoryCount(category);
	}
	
	@Override
	public OmsPage<CategoryVo> findByCategory(CategoryVo category,Integer page,Integer size) {
		OmsPage<CategoryVo> pages = new OmsPage<CategoryVo>();
		pages.setTotal(repository.findByCategoryCount(category));
		List<CategoryEntity> list = repository.findByCategory(category,page = (page - 1) * size,size);
		pages.setResult(etoV(list));
		return pages;
	}

	@Override
	public List<CategoryVo> findByCategoryList(CategoryVo category) {

		return etoV(repository.findByCategoryList(category));
	}


}
